import React, { Component } from 'react';
import '../styles/Recommend.scss'
import * as service from '../api/index'

class Recommend extends Component {

    state = {
        recommendlist: []
    }
    async componentDidMount() {
        let res = await service.index_recommendlist()
        // console.log(res.data.list);
        this.setState({ recommendlist: res.data.list })
    }

    render() {
        return (
            <div className='recommend'>
                <div className="option">
                    <div className="title">
                        为你推荐
                    </div>
                </div>
                <div className="recommendlist">
                    {
                        this.state.recommendlist.map((item, index) => {
                            return (
                                <div className="item">
                                    <img src={item.pic} alt="" />
                                    <div className="text">
                                        <div className="name">
                                            {item.name}
                                        </div>
                                        <div className="time_addr">
                                            <div className="time">
                                                {item.time}
                                            </div>
                                            <div className="address">
                                                {item.address}
                                            </div>
                                        </div>
                                        <div className="price">
                                            ￥{item.price}
                                        </div>
                                    </div>
                                </div>
                            )
                        })
                    }
                </div>
            </div>
        );
    }
}

export default Recommend;